import { requestClient } from '#/api/request';

const getVectorSList = (
  userId: string,
  pageSize: number,
  currentPage: number,
  keyword: string,
) => {
  return requestClient.get(
    `/dsc-systemMS/dsc-vector-service/getVectorSList/${userId}/${pageSize}/${currentPage}?keyword=${keyword}`,
  );
};

const getShpFeatures = (fileName: any) => {
  return requestClient.get(`/geofile/getAtrr?shpName=${fileName}`);
};
const getFields = (ptName: string) => {
  return requestClient.get(`/dsc-systemMS/dsc-shp/getFields/${ptName}`);
};

const getNumericFields = (ptName: string) => {
  return requestClient.get(`/dsc-systemMS/dsc-shp/getNumericFields/${ptName}`);
};
const getUniqueValues = (ptName: string, field: string, method: string) => {
  return requestClient.get(
    `/dsc-systemMS/dsc-shp/getUniqueValues/${ptName}/${field}/${method}`,
  );
};
const getFeatureCount = (ptName: string) => {
  return requestClient.get(`/dsc-systemMS/dsc-shp/getFeatureCount/${ptName}`);
};

const deleteVectorService = (userId: string, mvtId: string) => {
  return requestClient.delete(
    `/dsc-systemMS/dsc-vector-service/delete/${userId}/${mvtId}`,
  );
};

const getAtrr = (ptName: string) => {
  return requestClient.get(
    `/dsc-systemMS/dsc-shp/getShpAttrInfoFromPG/${ptName}`,
  );
};

const getCenterAndAttrByFields = (ptName: string, fields: string[]) => {
  return requestClient.get(
    `/dsc-systemMS/dsc-shp/getCenterAndAttrByFields/${ptName}/${fields.join(',')}`,
  );
};

const getFieldsFromGeojson = (sourceId: string) => {
  return requestClient.get(`/dsc-systemMS/dsc-geojson/getFields/${sourceId}`);
};

const getAtrrsFromGeojson = (sourceId: string) => {
  return requestClient.get(`/dsc-systemMS/dsc-geojson/getAttrs/${sourceId}`);
};

const getUniqueValuesFromGeojson = (
  sourceId: string,
  field: string,
  method: string,
) => {
  return requestClient.get(
    `/dsc-systemMS/dsc-geojson/getUniqueValues/${sourceId}/${field}/${method}`,
  );
};

const getFeatureCountFromGeojson = (sourceId: string) => {
  return requestClient.get(
    `/dsc-systemMS/dsc-geojson/getFeatureCount/${sourceId}`,
  );
};
const getVectorSListByFileId = (fileId: string) => {
  return requestClient.get(
    `/dsc-systemMS/dsc-vector-service/getVectorSListByFileId/${fileId}`,
  );
};
export default {
  getVectorSList,
  deleteVectorService,
  getShpFeatures,
  getFields,
  getNumericFields,
  getUniqueValues,
  getFeatureCount,
  getAtrr,
  getCenterAndAttrByFields,
  getFieldsFromGeojson,
  getAtrrsFromGeojson,
  getUniqueValuesFromGeojson,
  getFeatureCountFromGeojson,
  getVectorSListByFileId,
};
